<?php
/**
 * GioCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@ninhgio.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2010-2011 GioCMS (http://cms.ninhgio.com)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @author		NinhGio - ninhgio@gmail
 * @since		1.0
 */

class Plugins_Adminaccess_Plugin extends Gio_Core_Plugin
{
	public function run()
	{
		$request = Gio_Core_Request::getInstance();
		$configs = Gio_Core_Config_Xml::getConfig('web');
		$adminPrefixUrl = $configs->admin->prefix_url;
		
		$currentUri = $request->getRequestUri();
		/**
		 * 7 is length of /admin/
		 */
		if (!$adminPrefixUrl || substr($currentUri, 0, 7) != "/$adminPrefixUrl/") {
			return;
		}
		//$ips = explode(',', $ips);
		//$ip = $request->getClientIp();
		//if (in_array($ip, $ips)) {
		$controllerFront = Gio_Core_Controller::getIntance();
		$controllerFront->setTemplate('admin');
		//}
	}
	
}